<template>
	<view class="container">
		<uni-section title="食物轮播图展示" sub-title="" type="line">
			<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000">
				<swiper-item v-for="(item,index) in list" :key="index">
					<view class="swiper-item">
						<image :src="'http://localhost:8090'+item.icon" mode="aspectFill" style="height: 150px;width: 100%;"></image>
					</view>
				</swiper-item>
			</swiper>
		</uni-section>
		
		<uni-section title="食物类别宫格展示" sub-title="" type="line">
			<uni-grid :column="3" style="background-color: white;">
				<uni-grid-item v-for="(item,index) in data" :key="index">
					<view  style="display:flex;flex-direction: column;justify-content: center;align-items: center;height: 100%;font-size: 14px;color: #000;">
						<image :src="'http://localhost:8090'+item.icon" mode="aspectFill" style="width: 80px;height: 80px;"></image>
						<view class="">{{item.typename}}</view>
					</view>
				</uni-grid-item>
			</uni-grid>
		</uni-section>
		
		<uni-section title="食物列表展示(3条)" sub-title="" type="line">
			<uni-list v-for="(item,index) in foodlist" :key="index">
				<uni-list-item :title="item.name" :thumb="'http://localhost:8090'+item.icon" thumb-size="lg" :rightText="'￥'+item.price+'元'" note=""></uni-list-item>
			</uni-list>
		</uni-section>
		
		<uni-section title="食物评论列表展示(3条)" sub-title="" type="line">
			<uni-list v-for="(item,index) in commit" :key="index">
				<uni-list-item :title="item.comment" thumbSize="lg" :rightText="item.postdate" note=""></uni-list-item>
				
			</uni-list>
		</uni-section>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:[],
				data:[],
				foodlist:[],
				commit:[]
			}
		},
		onLoad() {
		uni.request({
			url: 'http://localhost:8090/foodapp/foodSwiper/list',
			method: 'POST',
			data: {},
			success: res => {
				if(res.data.success){
					this.list=res.data.list;
				}
			},
			fail: () => {},
			complete: () => {}
		});	
		uni.request({
			url: 'http://localhost:8090/foodapp/foodType/list',
			method: 'POST',
			data:{},
			success: res => {
				if(res.data.success){
					this.data=res.data.list
				}
			},
			fail: () => {},
			complete: () => {}
		});
		uni.request({
						url: 'http://localhost:8090/foodapp/food/list',
						method: 'POST',
						data: {},
						success: res => {
							if (res.data.success) {
								console.log(res)
								this.foodlist = res.data.list;
							}
						},
					});
					uni.request({
									url: 'http://localhost:8090/foodapp/comment/list',
									method: 'POST',
									data: {},
									success: res => {
										if (res.data.success) {
											console.log(res)
											this.commit = res.data.list;
										}
									},
								});
		},
		methods: {

		}
	}
</script>

<style>
	.container {
		padding: 20px;
		font-size: 14px;
		line-height: 24px;
	}
</style>
